package game.platformer.interfaces;
import game.platformer.platformer;
import org.anddev.andengine.engine.camera.Camera;
import org.anddev.andengine.entity.scene.Scene;
public class screenManager {
	//game data-------------------
	private platformer game;
	private Camera camera;
	//screens---------------------
	private MapScreen mapScreen = null;
	private MainMenuScreen mainScreen = null;
	private HudScreen hudscr = null;
	//boolean tests---------------
	private boolean hudIsAttatched;
	private boolean mapScrIsAttatched;
	//----------------------------
	/**
	 * should be created in platformer
	 * @param g the game itself
	 * @param cam the games camera
	 */
	public screenManager(platformer g, Camera cam){
		//save game references for use by screens
		camera = cam;
		game = g;

		//load resources-----
		mapScreen = new MapScreen(game, camera);
		mainScreen = new MainMenuScreen(game, camera);
		hudscr = new HudScreen(game, camera);

		//attatch the hud----
		camera.setHUD(hudscr);

		//boolean tests------
		hudIsAttatched = false;
		mapScrIsAttatched = false;
	}
	//mapscreen-------------------
	public MapScreen getMapScreen(){
		return mapScreen;
	}
	public void activateMapScreen(){
		if(!mapScrIsAttatched){
			mapScreen.attatch();
			mapScrIsAttatched = true;
			activateHudScreen();
		}

	}
	public void deactivateMapScreen(){
		if(mapScrIsAttatched){
			mapScreen.detatch();
			mapScrIsAttatched = false;
			deactivateHudScreen();
		}
	}
	//----------------------------
	//main menu screen------------
	public MainMenuScreen getMainMenuScreen(){
		return mainScreen;
	}
	public void activateMainMenuScreen(){
		if(mapScrIsAttatched){
			deactivateMapScreen();
		}
		if(hudIsAttatched){
			deactivateHudScreen();
		}
		game.getEngine().setScene(mainScreen);
	}
	//----------------------------
	//Hud-------------------------
	public HudScreen getHudScreen(){
		return hudscr;
	}
	public void activateHudScreen(){
		if(!hudIsAttatched){
			hudscr.attach();
			hudIsAttatched = true;
		}
	}
	public void deactivateHudScreen(){
		if(hudIsAttatched){
			hudscr.remove();
			hudIsAttatched = false;
		}
	}
	//----------------------------
}
